/*
 * AnimatorDB.cpp
 *
 *  Created on: 29.03.2012
 *      Author: Caffeine
 */


#ifdef __GAME__

#include "AnimatorDB.h"

namespace irr{
namespace core{
void AnimatorDB::regAnimator(irr::core::stringc name,EVENT_animatorCreate creator){
	animators.insert(name,creator);
}

bool AnimatorDB::isAnimationExist(irr::core::stringc name){
	irr::core::map<irr::core::stringc,EVENT_animatorCreate>::Node*f;
	f=animators.find(name);
	if (f==0){
		return false;
	}
	return true;
}

irr::scene::ISceneNodeAnimator*AnimatorDB::getAnimator(irr::core::stringc name,irr::NodeParams*params){
	irr::core::map<irr::core::stringc,EVENT_animatorCreate>::Node*f;
	f=animators.find(name);
	if (f==0){
		return 0;
	}
	return f->getValue()(params);
}

void AnimatorDB::setAnimator(irr::core::stringc name,irr::scene::ISceneNode*parent,NodeParams*params){
	irr::scene::ISceneNodeAnimator*anim=getAnimator(name,params);
	parent->addAnimator(anim);
	anim->drop();
}

}//namespace core
}//namespace irr

#endif
